package com.jz.community.basecomm.utils;

import android.content.Context;

import com.jz.community.basecomm.constant.AppConstants;
import com.jz.community.basecomm.constant.Constant;
import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;


public class WXLaunchMiniProgramUtils {

    private IWXAPI api;

    public WXLaunchMiniProgramUtils(Context context) {
        api = WXAPIFactory.createWXAPI(context, AppConstants.WX_APP_ID);
    }

    public void launchMiniProgram(String path) {
        WXLaunchMiniProgram.Req req = new WXLaunchMiniProgram.Req();
        req.userName = AppConstants.WX_LAUNCH_MINI_PROGRAM; // 填小程序原始id
        req.path = path;                  //拉起小程序页面的可带参路径，不填默认拉起小程序首页
        req.miniprogramType = Constant.WX_LAUNCH_MINI_PROGRAM_TYPE;// 可选打开 开发版，体验版和正式版
        api.sendReq(req);
    }
}
